home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1878 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: news.interlog.com!not-for-mail
  2. From: monteith@interlog.com (Mike Monteith)
  3. Newsgroups: comp.lang.c
  4. Subject: HELP:  Redirecting stdout problem
  5. Date: 17 Jan 1996 10:32:31 -0500
  6. Organization: Interlog Internet Services -Voice (416) 975-2655 -Data 515-1414
  7. Message-ID: <4dj4qf$4e9@gold.interlog.com>
  8. NNTP-Posting-Host: gold.interlog.com
  9. Summary: Problem restoring stdout to "CON"sole after child process is executed.
  10. Keywords: C HELP
  11.  
  12. Compiler:  MSVC 2.0
  13. Target:    WIN32 Console App.
  14.  
  15. Problem:
  16.  
  17.     The following code snippet successfully redirects stdout to the temporary
  18. file, but the attempt to restore stdout to the console fails.  Any Ideas?
  19. Please reply by e-mail to monteith@interlog.com.
  20.  
  21.  
  22. Thanks in advance
  23.  
  24. Mike
  25.  
  26. ************* Code *****************
  27.  
  28. FILE *stream;
  29.     
  30.     stream = freopen("TEMP.OUT", "w", stdout)
  31.  
  32.     _spawnvpe(_P_WAIT, ProgName, Args, Env);
  33.  
  34.     stream = freopen("CON", "w", stdout);
  35.  
  36. Note:
  37.  
  38. 1.  The first freopen works fine. All of the console output from the
  39.     spawned process is written to TEMP.OUT.
  40. 2.  Second freopen returns NULL (failure).
  41.  
  42.  
  43.  
  44.